﻿using CQIE.JonJack.Models.Tabels;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CQIE.JonJack.Models
{
    public class _DbContext : DbContext
    {
        public DbSet<Book> Books { get; set; }

        public DbSet<Role> Roles { get; set; }

        public DbSet<User> User { get; set; }

        public DbSet<BorrowRecord> BorrowRecord { get; set; }

        public DbSet<BookHistory> BookHistory { get; set; }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            base.OnConfiguring(optionsBuilder);
            var connectString = "server=localhost;user=root;password=zjk520;database=SplBookManage";
            var serverVersion = new MySqlServerVersion(new Version(8, 0, 34));
            optionsBuilder.UseMySql(connectString, serverVersion);
        }
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);
            modelBuilder.ApplyConfigurationsFromAssembly(this.GetType().Assembly);
        }
    }
}
